# import re
# from openpyxl import load_workbook
# import copy
# from .WordDB import WordSql
# import sys
# import os
#
#
# class DbUse:
#     def __int__(self):
#         self.userid = 0
#         self.wdsql = None
#         self.intcol = []
#         self.coursestileyuan = []
#         self.usertbcol = []
#         self.stname = []
#         self.courses = []
#         self.templatesname = []
#         self.coursepath = ''
#
#     def initdata(self):
#         self.wdsql = WordSql('127.0.0.1', 'root', 'zx.123456', 3306, 'word', 'utf8')
#         self.usertbcol = ['userid', 'name', 'password', 'major', 'administrators']
#         self.dictuserinfo = {
#             "userid": 0,
#             "name": "",
#             "password": "",
#             "major": "",
#             "administrators": "",
#         }
#         self.stname = ['通识课', '通识选修课', '学科基础课', '学科专业基础课', '专业选修课', '集中性实践', '第二课堂']
#         self.coursepath= "d:/word/excleapp/word/coursexlsx/"
#         # tmpall = []
#         # for i in wd.stname:
#         #     sql = "describe {}".format(i)
#         #     # print(sql)
#         #     tmp = []
#         #     for j in wd.wdsql.get_all(sql):
#         #         tmp.extend(j[0:1])
#         #     tmp = tmp[1:]
#         #     tmpall.append(tmp)
#         # self.coursestileyuan=tmpall
#         self.templatesname = ['目标', '要求', '预期', '主干学科', '主要实践性教学环节', '专业核心课程']
#         self.coursestileyuan = [
#             ('课程序号', '课程代码', '课程名称', '学时数', '学分数', '理论', '课内实践', '课外实践', '线上', '开课学期', '周学时', '考核方式', '备注', '毕业要求'),
#             ('课程序号', '课程代码', '课程名称', '学时数', '学分数', '理论', '课内实践', '课外实践', '线上', '开课学期', '周学时', '考核方式', '备注', '毕业要求'),
#             ('课程序号', '课程代码', '课程名称', '学时数', '学分数', '理论', '课内实践', '课外实践', '开课学期', '周学时', '考核方式', '备注', '毕业要求'),
#             ('课程序号', '课程代码', '课程名称', '学时数', '学分数', '理论', '课内实践', '课外实践', '开课学期', '周学时', '考核方式', '备注', '毕业要求'),
#             ('课程序号', '课程代码', '课程名称', '学时数', '学分数', '理论', '课内实践', '课外实践', '开课学期', '周学时', '考核方式', '备注', '毕业', '分组统计'),
#             ('序号', '课程代码', '课程名称', '实践周数', '学分数', '学期安排', '考核方式', '备注', '毕业要求'),
#             ('序号', '课程代码', '课程名称', '实践周数', '学分数', '学期安排', '考核方式', '备注')]
#         self.intcol = [8, 8, 7, 7, 7, 3, 3]
#         dbcoursestile = []
#         for i in self.coursestileyuan:
#             tmp = []
#             for j in i:
#                 tmp.append(j)
#             dbcoursestile.append(tmp[1:])
#         self.coursestile = dbcoursestile
#
#         self.createtbcourses(self.coursestileyuan)
#
#     def LoadCourse(self, w=None, userid=0, username=None, userpassord=None, major=None):
#         wd = load_workbook(w)
#         # wd = load_workbook('template/湘南学院/计算机科学与技术/' + 'course.xlsx')
#         # wd = load_workbook('template/湘南学院/物联网/' + 'course.xlsx')
#         coursestile = []
#         courses = []
#         for ipage in range(len(wd.worksheets)):
#             sheet = wd.worksheets[ipage]
#             data_course = list(sheet.values)
#             coursestile.append(data_course[0])
#             courses.append(data_course[1:])
#         self.coursestileyuan = coursestile
#         dbcourses = []
#         for i in courses:
#             tmp = []
#             for j in i:
#                 tmp.append(j[1:])
#             dbcourses.append(tmp)
#         self.courses = dbcourses
#         # self.insertuser(userid, username, userpassord, major)
#         # self.insertuser(userid, username, userpassord, major)
#         # if self.selectmajorcourses(major) == -1:
#         #     tbcourses = []
#         #     for i in self.courses:
#         #         tmp = []
#         #         for j in i:
#         #             tmpa = [major]
#         #             for k in j:
#         #                 tmpa.append(k)
#         #             tmp.append(tmpa)
#         #         tbcourses.append(tmp)
#         #     print(tbcourses)
#         #     self.insertcourse(tbcourses)
#         # else:
#         #     tbcourses = []
#         #     for i in self.selectmajorcoursesyuan(major, courses):
#         #         tmp = []
#         #         for j in i:
#         #             tmpa = [major]
#         #             for k in j:
#         #                 tmpa.append(k)
#         #             tmp.append(tmpa)
#         #         print(tmp)
#         #         tbcourses.append(tmp)
#         #     print(tbcourses)
#         #     self.upcourses(tbcourses)
#
#     def processingget_allresult(self, data):
#         tmpall = []
#         # for tmp in list(map(list, data)):
#         for tmp in data:
#             tmpall.extend(tmp)
#         return tmpall
#
#     def processingcoursestile(self, data):
#         tmp = []
#         for i in range(len(self.courses)):
#             sqlinsert = "replace " + self.stname[i] + "(major," + "%s," * (len(self.coursestile[i]) - 1) + "%s)"
#             sqlinsert = self.cur.mogrify(sqlinsert, self.coursestile[i])
#             sqlinsert = re.sub('[\'"]', '', sqlinsert)
#             sqlinsert += "values(" + "%s," * (len(data[i][0]) - 1) + "%s)"
#             tmp.append(sqlinsert)
#         return tmp
#
#     # def insertcourse(self, data):
#     #     for i in range(len(self.stname)):
#     #         sqlinsert = "replace " + self.stname[i] + "(major," + "%s," * (len(self.coursestile[i]) - 1) + "%s)"
#     #         self.wdsql.insertcoursers(sqlinsert, self.coursestile[i], data[i])
#
#     def insertcourse(self, data):
#         try:
#             self.wdsql.connect()
#             for i in range(len(self.stname)):
#                 sqlinsert = "replace " + self.stname[i] + "(major," + "%s," * (len(self.coursestile[i]) - 1) + "%s)"
#                 self.wdsql.insertcoursers(sqlinsert, self.coursestile[i], data[i])
#             self.wdsql.conn.commit()
#             self.wdsql.close()
#         except Exception as result:
#             self.wdsql.conn.rollback()
#             print("课程插入失败,未知错误为%s", result)
#
#     # def upcourses(self, data):
#     #     for i in range(len(self.stname)):
#     #         sqlinsert = "replace " + self.stname[i] + "(major," + "%s," * (len(self.coursestileyuan[i]) - 1) + "%s)"
#     #         self.wdsql.insertcoursers(sqlinsert, self.coursestileyuan[i], data[i])
#     def upcourses(self, data):
#         try:
#             self.wdsql.connect()
#             for i in range(len(self.stname)):
#                 sqlinsert = "replace " + self.stname[i] + "(major," + "%s," * (len(self.coursestileyuan[i]) - 1) + "%s)"
#                 self.wdsql.insertcoursers(sqlinsert, self.coursestileyuan[i], data[i])
#         except Exception as result:
#             self.wdsql.conn.rollback()
#             print("课程更新失败,未知错误为%s", result)
#
#     def insertmain_user(self,userid,major,school):
#         majorid = self.selectmajor_id(major)
#         schoolid = self.selectschool_id(school)
#         sql = "INSERT ignore INTO main(userid,school,majorid) VALUES('{}','{}','{}')".format(userid, schoolid, majorid)
#         self.wdsql.insert(sql)
#
#
#
#     def insertschool(self,school):
#         sql = "INSERT ignore INTO school(mycollege) VALUES('{}')".format(school)
#         self.wdsql.insert(sql)
#
#     def insertmajor(self,major):
#         sql = "INSERT ignore INTO major(major) VALUES('{}')".format(major)
#         self.wdsql.insert(sql)
#
#
#     def insertuser(self, userid, name, password, major):
#         sql = "replace user(userid,name,password,major)values({},'{}','{}','{}')".format(userid, name, password, major)
#         self.wdsql.insert(sql)
#
#     def insertcourse1(self,data, mainid):
#         sql = "insert into 通识课(课程序号,课程代码,课程名称,学时数,学分数,理论,课内实践,课外实践,线上,开课学期,周学时,考核方式,备注,毕业要求) values(" \
#               "{mainidd},'{a}','{b}','{c}','{d}','{e}','{f}','{g}','{h}','{i}','{j}','{k}','{l}','{m}','{n}');".format(
#             a=data[0], b=data[1], c=data[2], d=data[3], e=data[4], f=data[5], g=data[6], h=data[7], i=data[8],
#             j=data[9],mainidd =mainid,
#             k=data[10], l=data[11], m=data[12], n=data[13])
#         self.wdsql.insert(sql)
#
#     # 给通识选修课 表插数据
#     def insertcourse2(self,data, mainid):
#         sql = "insert into 通识选修课(课程序号,课程代码,课程名称,学时数,学分数,理论,课内实践,课外实践,线上,开课学期,周学时,考核方式,备注,毕业要求) values(" \
#               "{mainidd},'{a}','{b}','{c}','{d}','{e}','{f}','{g}','{h}','{i}','{j}','{k}','{l}','{m}','{n}')".format(
#             a=data[0], b=data[1], c=data[2], d=data[3], e=data[4], f=data[5], g=data[6], h=data[7], i=data[8],
#             j=data[9], mainidd = mainid,
#             k=data[10], l=data[11], m=data[12], n=data[13]
#         )
#         self.wdsql.insert(sql)
#
#     # 给学科基础课 表插数据
#     def insertcourse3(self,data, mainid):
#         sql = "insert into 学科基础课(课程序号,课程代码,课程名称,学时数,学分数,理论,课内实践,课外实践,开课学期,周学时,考核方式,备注,毕业要求) values(" \
#               "{mainidd},'{a}','{b}','{c}','{d}','{e}','{f}','{g}','{h}','{i}','{j}','{k}','{l}','{m}')".format(
#             a=data[0], b=data[1], c=data[2], d=data[3], e=data[4], f=data[5], g=data[6], h=data[7], i=data[8],
#             j=data[9], mainidd = mainid,
#             k=data[10], l=data[11], m=data[12]
#         )
#         self.wdsql.insert(sql)
#
#     # 给学科专业基础课 表插数据
#     def insertcourse4(slef,data, mainid):
#         sql = "insert into 学科专业基础课(课程序号,课程代码,课程名称,学时数,学分数,理论,课内实践,课外实践,开课学期,周学时,考核方式,备注,毕业要求) values(" \
#               "{mainidd},'{a}','{b}','{c}','{d}','{e}','{f}','{g}','{h}','{i}','{j}','{k}','{l}','{m}')".format(
#             a=data[0], b=data[1], c=data[2], d=data[3], e=data[4], f=data[5], g=data[6], h=data[7], i=data[8],
#             j=data[9], mainidd=mainid,
#             k=data[10], l=data[11], m=data[12]
#         )
#         slef.wdsql.insert(sql)
#
#     # 给专业选修课 表插数据
#     def insertcourse5(self,data, mainid):
#         sql = "insert into 专业选修课(课程序号,课程代码,课程名称,学时数,学分数,理论,课内实践,课外实践,开课学期,周学时,考核方式,备注,毕业,分组统计) values(" \
#               "{mainidd},'{a}','{b}','{c}','{d}','{e}','{f}','{g}','{h}','{i}','{j}','{k}','{l}','{m}','{n}')".format(
#             a=data[0], b=data[1], c=data[2], d=data[3], e=data[4], f=data[5], g=data[6], h=data[7], i=data[8],
#             j=data[9], mainidd=mainid,
#             k=data[10], l=data[11], m=data[12], n=data[13]
#         )
#         self.wdsql.insert(sql)
#
#     # 给集中性实践  表插数据
#     def insertcourse6(self,data, mainid):
#         sql = "insert into 集中性实践(序号,课程代码,课程名称,实践周数,学分数,学期安排,考核方式,备注,毕业要求) values(" \
#               "{mainidd},'{a}','{b}','{c}','{d}','{e}','{f}','{g}','{h}','{i}')".format(
#             a=data[0], b=data[1], c=data[2], d=data[3], e=data[4], f=data[5], g=data[6], h=data[7], i=data[8], mainidd=mainid
#         )
#         self.wdsql.insert(sql)
#
#     # 给第二课堂  表查数据
#     def insertcourse7(self,data, mainid):
#         sql = "insert into 第二课堂(序号,课程代码,课程名称,实践周数,学分数,学期安排,考核方式,备注) values(" \
#               "{mainidd},'{a}','{b}','{c}','{d}','{e}','{f}','{g}','{h}')".format(
#             a=data[0], b=data[1], c=data[2], d=data[3], e=data[4], f=data[5], g=data[6], h=data[7], mainidd=mainid
#         )
#         self.wdsql.insert(sql)
#     def inserttemplates(self, major, data):
#         templatesdictinfo = self.selecttemplatesdictinfo(major)
#         print(major)
#         print(templatesdictinfo)
#         if templatesdictinfo == -1:
#             sql = "replace templates (major,目标, 要求, 预期, 主干学科, 主要实践性教学环节, 专业核心课程)values('{major}'," \
#                   "'{t}','{q}','{e}','{ms}','{st}','{mj}')".format(major=major, t=data[0], q=data[1], e=data[2],
#                                                                    ms=data[3], st=data[4], mj=data[5])
#             print(sql)
#             self.wdsql.insert(sql)
#         else:
#             print(templatesdictinfo['templatesid'])
#             sql = "replace templates (templatesid,major,目标, 要求, 预期, 主干学科, 主要实践性教学环节, 专业核心课程)values({templatesid},'{major}'," \
#                   "'{t}','{q}','{e}','{ms}','{st}','{mj}')".format(templatesid=templatesdictinfo['templatesid'],
#                                                                    major=major, t=data[0],
#                                                                    q=data[1], e=data[2], ms=data[3], st=data[4],
#                                                                    mj=data[5])
#             self.wdsql.insert(sql)
#
#     def insertcoursetemplates(self):
#         userinfo = self.selectuserdictinfo(self.userid)
#         coursetemplatedictinfo = self.selectcoursetemplates()
#         coursepath = self.coursepath +str(userinfo.get("userid")) + userinfo.get("major") + "course"
#         # print(coursepath,'coursepath')
#         if coursetemplatedictinfo != -1:
#             coursepath = self.coursepath + str(userinfo.get("userid")) + userinfo.get("major") + "course"+".xlsx"
#             sql = "replace coursetemplates (coursetemplatesid,userid,major,coursepath)values({coursetemplatesid},{userid},'{major}','{coursepath}')".format(
#                 coursetemplatesid=coursetemplatedictinfo.get('coursetemplatesid'), userid=userinfo.get("userid"),
#                 major=userinfo.get('major'), coursepath=coursepath
#             )
#         else:
#             sql = "replace coursetemplates (userid,major,coursepath)values({userid},'{major}','{coursepath}')".format(
#                 userid=userinfo.get("userid"), major=userinfo.get('major'), coursepath=coursepath
#             )
#         # print(sql)
#         self.wdsql.insert(sql)
#
#     # def insertmajorInformation(self, data, mainid):
#     #     for key in data.keys():
#     #         data1 = data[key].courses
#     #         for class_information in data1:
#     #             xh = class_information.dictData['课程序号']
#     #             number = class_information.dictData['课程代码']
#     #             if number == '':
#     #                 number = '暂无'
#     #             class_name = class_information.dictData['课程名称']
#     #             class_credits = class_information.dictData['学分数']
#     #             class_hour = class_information.dictData['学时数']
#     #             theory = class_information.dictData['理论']
#     #             in_class = class_information.dictData['课内实践']
#     #             out_class = class_information.dictData['课外实践']
#     #             opening_semester = class_information.dictData['开课学期']
#     #             weekend_hour = class_information.dictData['周学时']
#     #             assessment_method = class_information.dictData['考核方式']
#     #             if assessment_method == '':
#     #                 assessment_method = '暂无'
#     #             notes = class_information.dictData['备注']
#     #             if notes == '':
#     #                 notes = '暂无'
#     #             graduation = class_information.dictData['毕业要求']
#     #             if graduation == '':
#     #                 graduation = '暂无'
#     #             find_main = self.selectclassmain(mainid, key)
#     #             print(class_name,notes, graduation)
#     #             if find_main == -1:
#     #                 sql = "INSERT ignore INTO {}(mainid,课程序号,课程代码,课程名称,学分数,学时数,理论,课内实践,课外实践,开课学期,周学时," \
#     #                       "考核方式,备注,毕业,分组统计) VALUES" \
#     #                       "({},{},'{}','{}',{},{},{},{},{},{},{},{},'{}','{}','{}','{}')".\
#     #                     format(key, mainid, xh, number, class_name, class_credits, class_hour, theory, in_class, out_class,
#     #                            opening_semester, weekend_hour, opening_semester, assessment_method, notes, graduation, '有意义')
#     #                 self.wdsql.insert(sql)
#     #             if find_main == 1:
#     #                 sql = "UPDATE {} SET 课程序号={},课程代码='{}',课程名称='{}',学分数={},学时数={},理论={},课内实践={}," \
#     #                       "课外实践={},开课学期{},周学时={},考核方式='{}',备注='{}',毕业='{}' WHERE mainid={};".format(key, xh, number, class_name, class_credits, class_hour, theory, in_class, out_class,
#     #                            opening_semester, weekend_hour, opening_semester, assessment_method, notes, graduation,
#     #                                                                                                 mainid)
#     #                 self.wdsql.update(sql)
#     #
#     #
#     #
#     #
#     #
#
#     def updateusermajor(self, userid, major):
#         sql = "update user set major= '{a}' where userid = {b}".format(b=userid, a=major)
#         self.wdsql.update(sql)
#
#     def createtbcourses(self, data=[]):
#         sqlcreatetbuser = "create table if not exists user (userid int(10) auto_increment primary key,name char(20) not null," \
#                           "password char(30) default '123456',major char(30))DEFAULT CHARSET=utf8;"
#         self.wdsql.create(sqlcreatetbuser)
#         tmp = self.templatesname
#         sqlcreatemain = "create table if not exists main (mainid int(10) auto_increment primary key,userid int(10) not null," \
#                         "school int(10) not null ,ma" \
#                         "jorid int(10) ,manageid int(10),userimpormationid int(10),majorimphmationid int(10),templatesid int(10),coursetemplatesid int(10))DEFAULT CHARSET=utf8;"
#         self.wdsql.create(sqlcreatemain)
#
#         sqlcreatmajor = "create table if not exists major (majorid int(10) auto_increment primary key, major char(30) UNIQUE KEY) DEFAULT CHARSET=utf8;"
#
#         self.wdsql.create(sqlcreatmajor)
#
#         sqlcreatmanage = "create table if not exists major (majorid int(10) auto_increment primary key, manage int(5) UNIQUE KEY) DEFAULT CHARSET=utf8;"
#
#
#         sqlcreatetbtemplates = "create table if not exists templates (templatesid int(10) auto_increment primary key," \
#                                "major char(30)," + "{} TEXT default null," * (len(self.templatesname) - 1) + \
#                                "{} TEXT default null)DEFAULT CHARSET=utf8;"
#         sqlcreatecoursetemplates = "create table if not exists coursetemplates (coursetemplatesid int (10) auto_increment primary key," \
#                                    "userid int(10),major char(30),coursepath TEXT, year int(10)not null)default charset=utf8;"
#         self.wdsql.create(sqlcreatecoursetemplates)
#         # sqlcreatetbschool = "create table if not exists school (schollid int(10) auto_increment primary key , school char(20)not null)DEFAULT CHARSET=utf8;"
#         # self.wdsql.create(sqlcreatetbschool)
#         # sqlcreatetbmajor = "create table if not exists major (majorid int(10) auto_increment primary key , major char(20)not null)DEFAULT CHARSET=utf8;"
#         # self.wdsql.create(sqlcreatetbmajor)
#         # sqlcreatetbf not exists school(schoolid int
#         sqlcreateschool = "create table if not exists school(schoolid int(10) auto_increment primary key,mycollege char(30) UNIQUE KEY);"
#         self.wdsql.create(sqlcreateschool)
#         sqlcreatetbtemplates = sqlcreatetbtemplates.format(tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5])
#         self.wdsql.create(sqlcreatetbtemplates)
#         # 创建课程表
#         for i in range(len(self.coursestileyuan)):
#             sqlcreatetb = "create table if not exists " + self.stname[
#                 i] + "(mainid int(10),%s int(10) auto_increment primary key," + \
#                           "%s char(30) default null," * 2 + "%s float(10) default 0," * (self.intcol[i]) + \
#                           "%s char(30) default null," * (len(data[i]) - (4 + self.intcol[i])) + \
#                           "%s char(60) default null)DEFAULT CHARSET=utf8;"
#             self.wdsql.createone(sqlcreatetb, data[i])
#
#     def selectcoursetemplates(self):
#         user = self.selectuserdictinfo(self.userid)
#         sql = "select * from coursetemplates where userid = {userid} and major = '{major}'".format(
#             userid=user.get("userid"), major=user.get('major'))
#         coursetemplatesdictinfo = self.wdsql.get_onedict(sql)
#         if coursetemplatesdictinfo == None:
#             return -1
#         return coursetemplatesdictinfo
#
#     def selectmajorfromcourseslist(self):
#         sql = "select major from 通识课 group by major"
#         majors = self.wdsql.get_all(sql)
#         if majors == None:
#             return -1
#         tmpall = []
#         for i in range(len(self.processingget_allresult(majors))):
#             tmp = dict(id=i + 1, major=self.processingget_allresult(majors)[i])
#             tmpall.append(tmp)
#         return tmpall
#
#
#     def selectcoursetemplatesslist(self):
#         user = self.selectuserdictinfo(self.userid)
#         sql = "select major from coursetemplates where userid = {userid}".format(
#             userid=user.get("userid"))
#         majors = self.wdsql.get_all(sql)
#         if majors == None:
#             return -1
#         tmpall = []
#         for i in range(len(self.processingget_allresult(majors))):
#             tmp = dict(id=i + 1, major=self.processingget_allresult(majors)[i])
#             tmpall.append(tmp)
#         return tmpall
#
#     def selectclassmain(self,mainid,key):
#         sql = "select * from {} where mainid ='{}'".format(key,mainid)
#         classinfo = self.wdsql.get_onedict(sql)
#         if classinfo == None:
#             return -1
#         return 1
#
#
#     def selectschool_id(self,school): #查找学校的id
#         sql = "select * from school where mycollege ='{}'".format(school)
#         schoolinfo = self.wdsql.get_onedict(sql)
#
#         if schoolinfo == None:
#             return -1
#         else:
#             schoolid = schoolinfo.get("schoolid")
#             return schoolid
#
#     def selectmajor_id(self, major):
#         sql = "select * from major where major='{}'".format(major)
#         major_dice = self.wdsql.get_onedict(sql)
#
#         if major_dice == None:
#             return -1
#         else:
#             majorid = major_dice.get("majorid")
#             return majorid
#
#     def selecttemplateseid(self,major):
#         sql = "select * from templates where major = '{}'".format(major)
#         templates_dice=self.wdsql.get_onedict(sql)
#
#
#         if templates_dice == None:
#             return -1
#         else:
#             templatesid= templates_dice.get("templatesid")
#             return templatesid
#
#     def selectuserdictinfo(self, userid):
#         sql = "select * from user where userid={}".format(userid)
#         userinfo = self.wdsql.get_onedict(sql)
#         if userinfo == None:
#             return -1
#         return userinfo
#
#     def selecttemplatesdict(self, major):
#         sql = "select *from templates where major='{major}'".format(major=major)
#         print(sql)
#         templatesdictinfo = self.wdsql.get_onedict(sql)
#         if templatesdictinfo == None:
#             templatesdictinfo = dict.fromkeys(self.templatesname, "")
#             return templatesdictinfo
#         return templatesdictinfo
#
#     def selecttemplatesdictinfo(self, major):
#         sql = "select *from templates where major='{major}'".format(major=major)
#         print(sql)
#         templatesdictinfo = self.wdsql.get_onedict(sql)
#         if templatesdictinfo == None:
#             return -1
#         return templatesdictinfo
#
#     def selectuserlistinfo(self, userid):
#         sql = self.cur.mogrify("select * from user where userid=%s", userid)
#         userinfo = self.wdsql.get_all(sql)
#         if userinfo == ():
#             return -1
#         tmp = []
#         for i in userinfo:
#             tmp.extend(i)
#         userinfo = tmp
#         self.LoadUDictUserInfo(userinfo)
#         return self.dictuserinfo
#
#     def selectmajorcourses(self, major):
#         tmpall = []
#         for course in self.stname:
#             sql = "select* from {c} where major='{m}'".format(c=course, m=major)
#             tmp = []
#             if self.wdsql.get_one(sql) == () or self.wdsql.get_one(sql) == None:
#                 return -1
#             for i, data in enumerate(self.wdsql.get_all(sql)):
#                 data = list(data[2:])
#                 data.insert(0, i + 1)
#                 tmp.append(data)
#             tmpall.append(tmp)
#         return tmpall
#
#     def selectmajorcoursesyuan(self, major, courses):
#         tmpall = []
#         for i, course in enumerate(self.stname):
#             sql = "select* from {c} where major='{m}'".format(c=course, m=major)
#             tmp = []
#             if self.wdsql.get_one(sql) == () or self.wdsql.get_one(sql) == None:
#                 return -1
#             for j, data in enumerate(self.wdsql.get_all(sql)):
#                 tmpcourse = list(courses[i][j][1:])
#                 tmpcourse.insert(0, data[1])
#                 tmp.append(tmpcourse)
#             tmpall.append(tmp)
#         return tmpall
#     def selectmainidpassuserid(self,userid):
#         sql = "select * from main where userid={}".format(userid)
#         mainidinfo = self.wdsql.get_onedict(sql)
#
#         if mainidinfo == None:
#             return -1
#         else:
#             mainid = mainidinfo.get("mainid")
#             return mainid
#
#     def cleartb(self):
#         tmp = []
#         for table in wd.wdsql.get_all('show tables'):
#             tmp.extend(table)
#         # tmp = copy.deepcopy(self.stname)
#         # tmp.insert(0, 'user')
#         # for i in tmp:
#         for i in self.stname:
#             sql = "drop table %s" % i
#             sql = re.sub('\'', "", sql)
#             self.wdsql.delete(sql)
#
#
# if __name__ == '__main__':
#     wd = DbUse()
#     wd.initdata()
#     # wd.LoadCourse(0, 123, 'admin', '123456', "计算机科学与技术")
#     # wd.LoadCourse(0, 123, 'admin', '123456', "物联网")
#     # wd.insertuser(123, 'admin', '123456', '计算机科学与技术')
#     print(wd.selectuserdictinfo(123))
#     # wd.updateusermajor(2,"物联网")
#     wd.cleartb()
#     print(wd.selectmajorfromcourseslist())
#     dbmajor = wd.selectmajorfromcourseslist()
